package com.py.pythink.controller;

import com.alibaba.fastjson.JSON;
import com.py.pythink.config.RedisKeyConfig;
import com.py.pythink.config.SystemConfig;
import com.py.pythink.entity.User;
import com.py.pythink.service.intf.UserLikeService;
import com.py.pythink.third.JedisUtil;
import com.py.pythink.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/ulike/")
@CrossOrigin
public class UserLikeController {
    @Autowired
    private UserLikeService service;
    @PostMapping("dianzan")
    public R djok(int fuid, HttpServletRequest request){
        String header = request.getHeader(SystemConfig.USER_TOKEN);
        User user = JSON.parseObject(JedisUtil.getStr(RedisKeyConfig.USER_TOKEN + header), User.class);
        return service.djok(fuid,user.getId());
    }
}
